 /* Copyright 2018 JDCLOUD.COM

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http:#www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.





Contact: 

NOTE: This class is auto generated by the jdcloud code generator program.
*/


#import <Foundation/Foundation.h>
#import <JDCloudOCSDKPipeline/PipelineModel.h>

@implementation NameLabelPair
-(id) initWithName:(NSString*) name
      label:(NSString*)label { 
     self.name = name;               
     self.label = label;               
    return self;
}

-(NSMutableDictionary*) dictionary{
    NSMutableDictionary* result = [[NSMutableDictionary alloc] init];
    if([self name])
    {
        [result setValue:[self name] forKey:@"name"];
    }
    if([self label])
    {
        [result setValue:[self label] forKey:@"label"];
    }
    return result;
}

-(id) initWithDic:(NSDictionary*)dictionary{
    self.name = [dictionary objectForKey:@"name"];
    self.label = [dictionary objectForKey:@"label"];
    return self;
}
 @end
@implementation ActionTypeId
-(id) initWithCategory:(NSString*) category
      owner:(NSString*)owner
      provider:(NSString*)provider
      version:(NSNumber*)version { 
     self.category = category;               
     self.owner = owner;               
     self.provider = provider;               
     self.version = version;               
    return self;
}

-(NSMutableDictionary*) dictionary{
    NSMutableDictionary* result = [[NSMutableDictionary alloc] init];
    if([self category])
    {
        [result setValue:[self category] forKey:@"category"];
    }
    if([self owner])
    {
        [result setValue:[self owner] forKey:@"owner"];
    }
    if([self provider])
    {
        [result setValue:[self provider] forKey:@"provider"];
    }
    if([self version])
    {
        [result setValue:[self version] forKey:@"version"];
    }
    return result;
}

-(id) initWithDic:(NSDictionary*)dictionary{
    self.category = [dictionary objectForKey:@"category"];
    self.owner = [dictionary objectForKey:@"owner"];
    self.provider = [dictionary objectForKey:@"provider"];
    self.version = [dictionary objectForKey:@"version"];
    return self;
}
 @end
@implementation ActionLink
-(id) initWithLabel:(NSString*) label
      url:(NSString*)url { 
     self.label = label;               
     self.url = url;               
    return self;
}

-(NSMutableDictionary*) dictionary{
    NSMutableDictionary* result = [[NSMutableDictionary alloc] init];
    if([self label])
    {
        [result setValue:[self label] forKey:@"label"];
    }
    if([self url])
    {
        [result setValue:[self url] forKey:@"url"];
    }
    return result;
}

-(id) initWithDic:(NSDictionary*)dictionary{
    self.label = [dictionary objectForKey:@"label"];
    self.url = [dictionary objectForKey:@"url"];
    return self;
}
 @end
@implementation PipelineParams
-(id) initWithName:(NSString*) name
      content:(NSString*)content
      method:(NSString*)method { 
     self.name = name;               
     self.content = content;               
     self.method = method;               
    return self;
}

-(NSMutableDictionary*) dictionary{
    NSMutableDictionary* result = [[NSMutableDictionary alloc] init];
    if([self name])
    {
        [result setValue:[self name] forKey:@"name"];
    }
    if([self content])
    {
        [result setValue:[self content] forKey:@"content"];
    }
    if([self method])
    {
        [result setValue:[self method] forKey:@"method"];
    }
    return result;
}

-(id) initWithDic:(NSDictionary*)dictionary{
    self.name = [dictionary objectForKey:@"name"];
    self.content = [dictionary objectForKey:@"content"];
    self.method = [dictionary objectForKey:@"method"];
    return self;
}
 @end
@implementation SimplePipeline
-(id) initWithUuid:(NSString*) uuid
      name:(NSString*)name
      startedAt:(NSNumber*)startedAt
      latestStatus:(NSString*)latestStatus
      latestInstanceUuid:(NSString*)latestInstanceUuid { 
     self.uuid = uuid;               
     self.name = name;               
     self.startedAt = startedAt;               
     self.latestStatus = latestStatus;               
     self.latestInstanceUuid = latestInstanceUuid;               
    return self;
}

-(NSMutableDictionary*) dictionary{
    NSMutableDictionary* result = [[NSMutableDictionary alloc] init];
    if([self uuid])
    {
        [result setValue:[self uuid] forKey:@"uuid"];
    }
    if([self name])
    {
        [result setValue:[self name] forKey:@"name"];
    }
    if([self startedAt])
    {
        [result setValue:[self startedAt] forKey:@"startedAt"];
    }
    if([self latestStatus])
    {
        [result setValue:[self latestStatus] forKey:@"latestStatus"];
    }
    if([self latestInstanceUuid])
    {
        [result setValue:[self latestInstanceUuid] forKey:@"latestInstanceUuid"];
    }
    return result;
}

-(id) initWithDic:(NSDictionary*)dictionary{
    self.uuid = [dictionary objectForKey:@"uuid"];
    self.name = [dictionary objectForKey:@"name"];
    self.startedAt = [dictionary objectForKey:@"startedAt"];
    self.latestStatus = [dictionary objectForKey:@"latestStatus"];
    self.latestInstanceUuid = [dictionary objectForKey:@"latestInstanceUuid"];
    return self;
}
 @end
@implementation Pipeline
-(id) initWithUuid:(NSString*) uuid
      createdAt:(NSNumber*)createdAt
      updatedAt:(NSNumber*)updatedAt
      name:(NSString*)name
      content:(NSString*)content { 
     self.uuid = uuid;               
     self.createdAt = createdAt;               
     self.updatedAt = updatedAt;               
     self.name = name;               
     self.content = content;               
    return self;
}

-(NSMutableDictionary*) dictionary{
    NSMutableDictionary* result = [[NSMutableDictionary alloc] init];
    if([self uuid])
    {
        [result setValue:[self uuid] forKey:@"uuid"];
    }
    if([self createdAt])
    {
        [result setValue:[self createdAt] forKey:@"createdAt"];
    }
    if([self updatedAt])
    {
        [result setValue:[self updatedAt] forKey:@"updatedAt"];
    }
    if([self name])
    {
        [result setValue:[self name] forKey:@"name"];
    }
    if([self content])
    {
        [result setValue:[self content] forKey:@"content"];
    }
    return result;
}

-(id) initWithDic:(NSDictionary*)dictionary{
    self.uuid = [dictionary objectForKey:@"uuid"];
    self.createdAt = [dictionary objectForKey:@"createdAt"];
    self.updatedAt = [dictionary objectForKey:@"updatedAt"];
    self.name = [dictionary objectForKey:@"name"];
    self.content = [dictionary objectForKey:@"content"];
    return self;
}
 @end
@implementation ActionLinks
-(id) initWithProvider:(ActionLink*) provider
      status:(ActionLink*)status
      detail:(ActionLink*)detail { 
     self.provider = provider;               
     self.status = status;               
     self.detail = detail;               
    return self;
}

-(NSMutableDictionary*) dictionary{
    NSMutableDictionary* result = [[NSMutableDictionary alloc] init];
    if([self provider])
    {
        [result setValue:[[self provider] dictionary]forKey:@"provider"];
    }
    if([self status])
    {
        [result setValue:[[self status] dictionary]forKey:@"status"];
    }
    if([self detail])
    {
        [result setValue:[[self detail] dictionary]forKey:@"detail"];
    }
    return result;
}

-(id) initWithDic:(NSDictionary*)dictionary{
    self.provider = [[ActionLink alloc]initWithDic:[dictionary objectForKey:@"provider"]];
    self.status = [[ActionLink alloc]initWithDic:[dictionary objectForKey:@"status"]];
    self.detail = [[ActionLink alloc]initWithDic:[dictionary objectForKey:@"detail"]];
    return self;
}
 @end
@implementation PipelineAction
-(id) initWithUuid:(NSString*) uuid
      name:(NSString*)name
      createdAt:(NSNumber*)createdAt
      startedAt:(NSNumber*)startedAt
      doneAt:(NSNumber*)doneAt
      status:(NSNumber*)status
      statusHuman:(NSString*)statusHuman
      links:(ActionLinks*)links
      actionTypeId:(ActionTypeId*)actionTypeId { 
     self.uuid = uuid;               
     self.name = name;               
     self.createdAt = createdAt;               
     self.startedAt = startedAt;               
     self.doneAt = doneAt;               
     self.status = status;               
     self.statusHuman = statusHuman;               
     self.links = links;               
     self.actionTypeId = actionTypeId;               
    return self;
}

-(NSMutableDictionary*) dictionary{
    NSMutableDictionary* result = [[NSMutableDictionary alloc] init];
    if([self uuid])
    {
        [result setValue:[self uuid] forKey:@"uuid"];
    }
    if([self name])
    {
        [result setValue:[self name] forKey:@"name"];
    }
    if([self createdAt])
    {
        [result setValue:[self createdAt] forKey:@"createdAt"];
    }
    if([self startedAt])
    {
        [result setValue:[self startedAt] forKey:@"startedAt"];
    }
    if([self doneAt])
    {
        [result setValue:[self doneAt] forKey:@"doneAt"];
    }
    if([self status])
    {
        [result setValue:[self status] forKey:@"status"];
    }
    if([self statusHuman])
    {
        [result setValue:[self statusHuman] forKey:@"statusHuman"];
    }
    if([self links])
    {
        [result setValue:[[self links] dictionary]forKey:@"links"];
    }
    if([self actionTypeId])
    {
        [result setValue:[[self actionTypeId] dictionary]forKey:@"actionTypeId"];
    }
    return result;
}

-(id) initWithDic:(NSDictionary*)dictionary{
    self.uuid = [dictionary objectForKey:@"uuid"];
    self.name = [dictionary objectForKey:@"name"];
    self.createdAt = [dictionary objectForKey:@"createdAt"];
    self.startedAt = [dictionary objectForKey:@"startedAt"];
    self.doneAt = [dictionary objectForKey:@"doneAt"];
    self.status = [dictionary objectForKey:@"status"];
    self.statusHuman = [dictionary objectForKey:@"statusHuman"];
    self.links = [[ActionLinks alloc]initWithDic:[dictionary objectForKey:@"links"]];
    self.actionTypeId = [[ActionTypeId alloc]initWithDic:[dictionary objectForKey:@"actionTypeId"]];
    return self;
}
 @end
@implementation PipelineStage
-(id) initWithUuid:(NSString*) uuid
      name:(NSString*)name
      createdAt:(NSNumber*)createdAt
      startedAt:(NSNumber*)startedAt
      doneAt:(NSNumber*)doneAt
      status:(NSNumber*)status
      statusHuman:(NSString*)statusHuman
      position:(NSNumber*)position
      actions:(NSArray<PipelineAction*>*)actions { 
     self.uuid = uuid;               
     self.name = name;               
     self.createdAt = createdAt;               
     self.startedAt = startedAt;               
     self.doneAt = doneAt;               
     self.status = status;               
     self.statusHuman = statusHuman;               
     self.position = position;               
     self.actions = actions;               
    return self;
}

-(NSMutableDictionary*) dictionary{
    NSMutableDictionary* result = [[NSMutableDictionary alloc] init];
    if([self uuid])
    {
        [result setValue:[self uuid] forKey:@"uuid"];
    }
    if([self name])
    {
        [result setValue:[self name] forKey:@"name"];
    }
    if([self createdAt])
    {
        [result setValue:[self createdAt] forKey:@"createdAt"];
    }
    if([self startedAt])
    {
        [result setValue:[self startedAt] forKey:@"startedAt"];
    }
    if([self doneAt])
    {
        [result setValue:[self doneAt] forKey:@"doneAt"];
    }
    if([self status])
    {
        [result setValue:[self status] forKey:@"status"];
    }
    if([self statusHuman])
    {
        [result setValue:[self statusHuman] forKey:@"statusHuman"];
    }
    if([self position])
    {
        [result setValue:[self position] forKey:@"position"];
    }
    if([self actions])
    {
        NSMutableArray<NSDictionary*>* arrayDic  = [[NSMutableArray alloc] init];
        for (int i =0 ; i< [[self actions] count]; i++) {
            PipelineAction* item = [[self actions] objectAtIndex:i];
            [arrayDic addObject:[item dictionary]];
        }
        [result setValue:arrayDic forKey:@"actions"];
    }
    return result;
}

-(id) initWithDic:(NSDictionary*)dictionary{
    self.uuid = [dictionary objectForKey:@"uuid"];
    self.name = [dictionary objectForKey:@"name"];
    self.createdAt = [dictionary objectForKey:@"createdAt"];
    self.startedAt = [dictionary objectForKey:@"startedAt"];
    self.doneAt = [dictionary objectForKey:@"doneAt"];
    self.status = [dictionary objectForKey:@"status"];
    self.statusHuman = [dictionary objectForKey:@"statusHuman"];
    self.position = [dictionary objectForKey:@"position"];
    NSArray* actionsArray = [dictionary objectForKey:@"actions"];
    if(actionsArray&&![actionsArray isKindOfClass:[NSNull class]])
    {
        NSMutableArray* propertyArray = [[NSMutableArray alloc]init];
        for(int i = 0 ; i< [actionsArray count];i++)
        {
            PipelineAction* item = [[PipelineAction alloc]initWithDic:[actionsArray objectAtIndex:i]];
            if(item)
            {
                [propertyArray addObject:item];
            }
        }
        self.actions = propertyArray;
    }
    return self;
}
 @end
@implementation PipelineInstance
-(id) initWithUuid:(NSString*) uuid
      startedAt:(NSNumber*)startedAt
      doneAt:(NSNumber*)doneAt
      durationMs:(NSNumber*)durationMs
      status:(NSNumber*)status
      statusHuman:(NSString*)statusHuman
      env:(NSString*)env
      failureReason:(NSNumber*)failureReason
      falseilureReasonHuman:(NSString*)falseilureReasonHuman
      stages:(NSArray<PipelineStage*>*)stages { 
     self.uuid = uuid;               
     self.startedAt = startedAt;               
     self.doneAt = doneAt;               
     self.durationMs = durationMs;               
     self.status = status;               
     self.statusHuman = statusHuman;               
     self.env = env;               
     self.failureReason = failureReason;               
     self.falseilureReasonHuman = falseilureReasonHuman;               
     self.stages = stages;               
    return self;
}

-(NSMutableDictionary*) dictionary{
    NSMutableDictionary* result = [[NSMutableDictionary alloc] init];
    if([self uuid])
    {
        [result setValue:[self uuid] forKey:@"uuid"];
    }
    if([self startedAt])
    {
        [result setValue:[self startedAt] forKey:@"startedAt"];
    }
    if([self doneAt])
    {
        [result setValue:[self doneAt] forKey:@"doneAt"];
    }
    if([self durationMs])
    {
        [result setValue:[self durationMs] forKey:@"durationMs"];
    }
    if([self status])
    {
        [result setValue:[self status] forKey:@"status"];
    }
    if([self statusHuman])
    {
        [result setValue:[self statusHuman] forKey:@"statusHuman"];
    }
    if([self env])
    {
        [result setValue:[self env] forKey:@"env"];
    }
    if([self failureReason])
    {
        [result setValue:[self failureReason] forKey:@"failureReason"];
    }
    if([self falseilureReasonHuman])
    {
        [result setValue:[self falseilureReasonHuman] forKey:@"falseilureReasonHuman"];
    }
    if([self stages])
    {
        NSMutableArray<NSDictionary*>* arrayDic  = [[NSMutableArray alloc] init];
        for (int i =0 ; i< [[self stages] count]; i++) {
            PipelineStage* item = [[self stages] objectAtIndex:i];
            [arrayDic addObject:[item dictionary]];
        }
        [result setValue:arrayDic forKey:@"stages"];
    }
    return result;
}

-(id) initWithDic:(NSDictionary*)dictionary{
    self.uuid = [dictionary objectForKey:@"uuid"];
    self.startedAt = [dictionary objectForKey:@"startedAt"];
    self.doneAt = [dictionary objectForKey:@"doneAt"];
    self.durationMs = [dictionary objectForKey:@"durationMs"];
    self.status = [dictionary objectForKey:@"status"];
    self.statusHuman = [dictionary objectForKey:@"statusHuman"];
    self.env = [dictionary objectForKey:@"env"];
    self.failureReason = [dictionary objectForKey:@"failureReason"];
    self.falseilureReasonHuman = [dictionary objectForKey:@"falseilureReasonHuman"];
    NSArray* stagesArray = [dictionary objectForKey:@"stages"];
    if(stagesArray&&![stagesArray isKindOfClass:[NSNull class]])
    {
        NSMutableArray* propertyArray = [[NSMutableArray alloc]init];
        for(int i = 0 ; i< [stagesArray count];i++)
        {
            PipelineStage* item = [[PipelineStage alloc]initWithDic:[stagesArray objectAtIndex:i]];
            if(item)
            {
                [propertyArray addObject:item];
            }
        }
        self.stages = propertyArray;
    }
    return self;
}
 @end
 
 


